/**
 * 项目名称: Topic_283.cpp
 * 项目路径: study/DataStructure/刷题/一轮/第九天 数组+指针
 * 编辑时间: 2024年09月10日20时11分41秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;

class Solution {
public:
    void moveZeroes(vector<int> &nums) {
        if (nums.empty())return;

        int j = 0;
        for (int i = 0; i < nums.size(); i++)
            if (nums[i] != 0) {
                int tmp = nums[i];
                nums[i] = nums[j];
                nums[j++] = tmp;
            }
    }
};

class Solution1 {
public:
    void moveZeroes(vector<int> &nums) {
        if (nums.empty())return;

        int j = 0;
        for (int i = 0; i < nums.size(); i++)
            if (nums[i] != 0)nums[j++] = nums[i];
        for (int i = j; i < nums.size(); i++)nums[i] = 0;
    }
};